<template>
    <div class="iframe">
        <div class="i-title">
            <h3>组件A</h3>
        </div>
        <div class="i-tip">
            {{ info.name }}，{{ info.age }}岁
        </div>
        <div class="i-tip">
            <el-button @click="send2">发送</el-button>
        </div>
    </div>
</template>
<script setup>
import { reactive, onMounted } from "vue"
import pubsub from "pubsub-js"
let info = reactive({
    name: "...",
    age: 18
})
function send2() {
    pubsub.publish("Age", info.age)
}
onMounted(() => {
    //订阅
    pubsub.subscribe("getName", (prop, data) => {
        info.name = data;
    })
})
</script>
